<?php


namespace app\common\models;


use app\common\traits\BaseModelOptionTrait;
use think\Model;

class Game extends Model
{
    use BaseModelOptionTrait;

    protected $table = 'xiangji_games';
    // 自动维护时间戳
    protected $autoWriteTimestamp = true;

    public static function onBeforeInsert($game)
    {
        // 自动添加app_id和app_secret
        $game->app_id = 'daw'.createAppId();
        $game->app_secret = createAppSecret($game->app_id);
    }

    public function setAccessIpsAttr($value)
    {
        return serialize($value);
    }

    public function getAccessIpsAttr($value)
    {
        return unserialize($value);
    }
}
